package com.tancire.web.controller.company;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tancire.common.annotation.Log;
import com.tancire.common.core.controller.BaseController;
import com.tancire.common.core.domain.AjaxResult;
import com.tancire.common.enums.BusinessType;
import com.tancire.net.domain.CrmCompanyLog;
import com.tancire.net.service.ICrmCompanyLogService;
import com.tancire.common.utils.poi.ExcelUtil;
import com.tancire.common.core.page.TableDataInfo;

/**
 * 客户操作日志Controller
 *
 * @author chenchao
 * @date 2023-12-25
 */
@RestController
@RequestMapping("/net/crmCompanyLog")
public class CrmCompanyLogController extends BaseController {
    @Resource
    private ICrmCompanyLogService crmCompanyLogService;

    /**
     * 查询客户操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('net:crmCompanyLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(CrmCompanyLog crmCompanyLog) {
        startPage();
        List<CrmCompanyLog> list = crmCompanyLogService.selectCrmCompanyLogList(crmCompanyLog);
        return getDataTable(list);
    }

    /**
     * 导出客户操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('net:crmCompanyLog:export')")
    @Log(title = "客户操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CrmCompanyLog crmCompanyLog) {
        List<CrmCompanyLog> list = crmCompanyLogService.selectCrmCompanyLogList(crmCompanyLog);
        ExcelUtil<CrmCompanyLog> util = new ExcelUtil<CrmCompanyLog>(CrmCompanyLog.class);
        util.exportExcel(response, list, "客户操作日志数据");
    }

    /**
     * 获取客户操作日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('net:crmCompanyLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(crmCompanyLogService.selectCrmCompanyLogById(id));
    }

    /**
     * 新增客户操作日志
     */
    @PreAuthorize("@ss.hasPermi('net:crmCompanyLog:add')")
    @Log(title = "客户操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CrmCompanyLog crmCompanyLog) {
        return toAjax(crmCompanyLogService.insertCrmCompanyLog(crmCompanyLog));
    }

    /**
     * 修改客户操作日志
     */
    @PreAuthorize("@ss.hasPermi('net:crmCompanyLog:edit')")
    @Log(title = "客户操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CrmCompanyLog crmCompanyLog) {
        return toAjax(crmCompanyLogService.updateCrmCompanyLog(crmCompanyLog));
    }

    /**
     * 删除客户操作日志
     */
    @PreAuthorize("@ss.hasPermi('net:crmCompanyLog:remove')")
    @Log(title = "客户操作日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(crmCompanyLogService.deleteCrmCompanyLogByIds(ids));
    }
}
